Graphene.jq("body");
Graphene is entry point for common one-line operations which are not possible to achieve by common Selenium API:
locator construction
waiting on conditions and retrieval
access to various conditions and retrievers
request-type guards
Main advantage of Graphene utility class is that it includes set of immutable static members, which can be used directly from your test:
Graphene.jq("body");
This concept is much stronger when using possibilities of your IDE for code completion. You can then statically import whole Graphene utility class to your test, which gives you access to all the static members and methods.
import static org.jboss.arquillian.ajocado.Graphene.*; JQueryLocator body = jq("body");
Note: You can use Eclipse Favorites feature and include Graphene into list of utility classes - you will get suggestions for code-completion out of the box.
Three kinds of configuration for objects which handles waiting for satisfaction of conditions taken as parameter.
waitGui - waits for a short time, typically waits for client-side operations
waitAjax - waits for longer time, typically ajax request with no computational load
waitModel - waits for a long time, typically database requests or other computationally hard operations
waitGui.until(textEquals.locator(...).text("Some text")); ... waitAjax.until(elementPresent.locator(...));
All timeouts for given types of waitings can be configured through GrapheneConfiguration.
The split into three groups does not required to be strictly followed, but is recommended to separate these request to adjust values for various platforms where tests will be run.
When are used together with waitings, they creates easy to follow API for waiting for condition definitions.
elementPresent
elementNotPresent
textEquals
styleEquals
attributePresent
attributeEquals
alertPresent
alertEquals
countEquals
elementVisible
elementNotVisible
Complementary for conditions, retrievers can wait for change of the value and then return the new one.
retrieveText
retrieveAttribute
Retriever<Integer> retrievePrice = integerAdapter(retrieveText.locator(...)); retrievePrice.initiliazeValue(); ... int newPrice = waitAjax.waitForChangeAndReturn(retrievePrice);
Guard are able to intercept Selenium command to verify that request which occurs after command is expected.
Guards can verify that HTTP or XHR request has been done or they can verify that no request has happened after command.
guardNoRequest - waits for specific amount of time to verify that no request happen after command
guardXhr
guardHttp
waitForXhr - when waiting for first XHR request to happen after command, several HTTP request can be done
waitForHttp - when waiting for first HTTP request to happen after command, several XHR requests can be done
guardXhr(selenium).click(button);
For shortening code and increasing readability, locator factories can be used to construct instances of locators.
IdLocator copyright = id("copyright"); JQueryLocator header = jq("div.header");
One specific locator factory is intended for composing locators:
XPathLocator row = child(tableRoot, xp("tbody/tr"));